import { defineStore } from 'pinia';

export const modelStore = defineStore('modelStore', {
  state: () => ({
    createModelObj: {},
    showModelId: 0,
    model_id: 0,
    runs_id: 0,
    version_id: 0,
    repository_model_id: 0,//创建模型详情id
    metric_key: '',//新添加评估数据历史接口-用于显示单个评估数据的图表
    isEditOrAdd: false,//区别系统用户新增还是修改
    localHostInfo: {},
    systemRowData: {},//系统用户修改保存行列数据
    compareModelVersions: [],//模型对比版本号
    errorData: '',
    model_operator: 0, //设计器实验算子id
    api_endpoint: {}//模型部署-app认证指南
  }),
  getters: {
    getApiEndpoint({api_endpoint}){
      return api_endpoint
    },
    getErrorData({errorData}){
      return errorData
    },
    getCompareModelVersions({compareModelVersions}){
      return compareModelVersions
    },
    getSystemRowData({systemRowData}){
      return systemRowData
    },
    getLocalHostInfo({localHostInfo}){
      return localHostInfo
    },
    getIsEditOrAdd({isEditOrAdd}){
      return isEditOrAdd
    }
  },
  actions: {
    setApiEndpoint(value:any){
      this.api_endpoint = value
    },
    setShowModelId(value:any){
      this.showModelId = value
    },
    setErrorData(value: any) {
      this.errorData = value
    },
    setCompareVersions(value:any){
      this.compareModelVersions = value
    },
    setSystemRowData(value:any){
      this.systemRowData = value
    },
    setIsEditOrAdd(value:boolean){
      this.isEditOrAdd = value;
    },
    setModelobj(obj: object) {
      this.createModelObj = obj
    },
    setMetricKey(value:string){
      this.metric_key = value
    },
    dataset(num: any) {
      this.model_id = num
    },
    dataRunsIdset(num: any) {
      this.runs_id = num
    },
    setRepositoryModelId(num: any){
      this.repository_model_id = num
    },
    setVersionId(num: any){
      this.version_id = num
    },
    setModelOperator(num: number) {
      this.model_operator = num
    }

  },
  persist: {
    enabled: true, //不单独设置则为默认全开
    strategies: [
      {
        // 自定义存储方式，默认sessionStorage
        storage: sessionStorage,
        // 指定要持久化的数据
        paths: ['createModelObj','api_endpoint', 'errorData','version_id','localHostInfo', 'model_id','runs_id','repository_model_id', 'runs_id','metric_key','isEditOrAdd','compareModelVersions']
      }
    ]
  }
});
